package com.caocaog.market.entity.vo;


import com.caocaog.market.entity.GoodsAttr;
import com.caocaog.market.entity.GoodsBase;
import com.caocaog.market.entity.GoodsSpec;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.experimental.Accessors;
import org.jeecg.common.aspect.annotation.Dict;

import java.io.Serializable;
import java.util.List;

@Getter
@Setter
@NoArgsConstructor
@Accessors(chain = true)
public class GoodsVO implements Serializable {
    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "商品id")
    private String id;

    @ApiModelProperty(value = "门店id")
    private String shopId;

    @ApiModelProperty(value = "商品分类id")
    private String sortId;

    @ApiModelProperty(value = "商品分类名称")
    private String sortName;

    @ApiModelProperty(value = "商品全称")
    private String name;

    @ApiModelProperty(value = "商品原价")
    private String originalPrice;

    @ApiModelProperty(value = "商品现价")
    private String presentPrice;

    @ApiModelProperty(value = "商品图片")
    private String picture;

    @ApiModelProperty(value = "浏览次数")
    private Integer visitNum;

    @ApiModelProperty(value = "销售数量")
    private Integer saleNum;

    @ApiModelProperty(value = "起售数量")
    private Integer salesQuantity;

    @ApiModelProperty(value = "商品描述")
    private String description;

    @ApiModelProperty(value = "是否热门商品")
    private Boolean hot;

    @ApiModelProperty(value = "是否单点不送")
    private Boolean oneNoDelivery;

    @ApiModelProperty(value = "是否是单个规格")
    private Boolean singleSpec;

    @ApiModelProperty(value = "商品描述")
    private String goodDetail;

    @ApiModelProperty(value = "商品销量")
    private String textMonthly;

    @Dict(dicCode = "mk_whether")
    @ApiModelProperty(value = "是否首页展示")
    private String isIndex;

    // TODO 等前端不再用 shortDescription 字段即可删除
    @Deprecated
    @ApiModelProperty(value = "商品简单描述")
    private String shortDescription;

    @ApiModelProperty(value = "商品规格信息")
    private List<GoodsSpec> goodsSpecificationsList;

    @ApiModelProperty(value = "商品属性信息")
    private List<GoodsAttr> goodsAttributeList;

    /**
     * 向前端返回VO数据之前的预处理，等TODO都解决后即可删除
     */
    public GoodsVO preprocess() {
        // TODO 等前端不再用 shortDescription 字段即可删除
        this.shortDescription = this.description;
        return this;
    }

    public GoodsVO(GoodsBase goodsBase) {
        this.isIndex = goodsBase.getIsIndex();
        this.id = goodsBase.getId();
        this.shopId = goodsBase.getShopId();
        this.sortId = goodsBase.getSorts();
        this.name = goodsBase.getName();
        this.originalPrice = goodsBase.getOriginalPrice();
        this.presentPrice = goodsBase.getPresentPrice();
        this.picture = goodsBase.getPicture();
        this.visitNum = goodsBase.getVisitNum();
        this.saleNum = goodsBase.getSaleNum();
        this.salesQuantity = goodsBase.getSalesQuantity();
        this.description = goodsBase.getDescription();
        this.hot = "1".equals(goodsBase.getIsHot());
        this.oneNoDelivery = "1".equals(goodsBase.getOneNoDelivery());
        this.singleSpec = goodsBase.getSingleSpec();
        this.goodDetail=goodsBase.getGoodDetail();
    }

}
